/*
 * Copyright 2022-2029 heshuixing(https://gitee.com/heshuixing)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mercury.ec.module.air.util;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.mercury.ec.module.air.dal.dataobject.order.AirOrderPriceDO;
import com.mercury.ec.module.air.enums.AirOrderTypeEnum;

import static com.mercury.ec.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.mercury.ec.module.air.enums.ErrorCodeConstants.AIR_ORDER_TYPE_NOT_SUPPORT;

/**
 * 订单工具类
 *
 * @author hesx
 */
public class AirOrderUtils {

    /**
     * 根据订单类型获取订单号
     *
     * @param orderId
     * @param type
     * @return
     */
    public static String getNo(long orderId, int type) {
        switch (AirOrderTypeEnum.getInstance(type)) {
            case SALE:
                return IdWorker.getIdStr();
            case CHANGE:
                return "C" + orderId;
            case RETURN:
                return "R" + orderId;
            case ADJUST:
                return "A" + orderId;
            default:
                throw exception(AIR_ORDER_TYPE_NOT_SUPPORT, type);
        }
    }

    /**
     * 退票单价格转负数
     *
     * @param airOrderPriceDO
     */
    public static void convertToMinus(AirOrderPriceDO airOrderPriceDO) {
        // 销售
//        airOrderPriceDO.setSaleAdditionalFee(airOrderPriceDO.getSaleAdditionalFee().negate());
//        airOrderPriceDO.setSaleServiceFee(airOrderPriceDO.getSaleServiceFee().negate());
        airOrderPriceDO.setSaleUpgradeFee(airOrderPriceDO.getSaleUpgradeFee().negate());
        airOrderPriceDO.setSaleChangeFee(airOrderPriceDO.getSaleChangeFee().negate());
//        airOrderPriceDO.setSaleReturnFee(airOrderPriceDO.getSaleReturnFee().negate());
        airOrderPriceDO.setSaleTicketPrice(airOrderPriceDO.getSaleTicketPrice().negate());
        airOrderPriceDO.setSalePrice(airOrderPriceDO.getSalePrice().negate());
        airOrderPriceDO.setSaleUsedPrice(airOrderPriceDO.getSaleUsedPrice().negate());
        airOrderPriceDO.setSaleAirportTax(airOrderPriceDO.getSaleAirportTax().negate());
        airOrderPriceDO.setSaleOilTax(airOrderPriceDO.getSaleOilTax().negate());
        airOrderPriceDO.setSaleTax(airOrderPriceDO.getSaleTax().negate());
//        airOrderPriceDO.setSaleAgencyFeeRate(airOrderPriceDO.getSaleAgencyFeeRate().negate());
//        airOrderPriceDO.setSaleAgencyFee(airOrderPriceDO.getSaleAgencyFee().negate());
//        airOrderPriceDO.setSaleBackRebateFeeRate(airOrderPriceDO.getSaleBackRebateFeeRate().negate());
//        airOrderPriceDO.setSaleBackRebateFee(airOrderPriceDO.getSaleBackRebateFee().negate());
        airOrderPriceDO.setSalePrizePrice(airOrderPriceDO.getSalePrizePrice().negate());
        airOrderPriceDO.setSalePrizeTax(airOrderPriceDO.getSalePrizeTax().negate());
        // 采购
//        airOrderPriceDO.setPurchaseAdditionalFee(airOrderPriceDO.getPurchaseAdditionalFee().negate());
//        airOrderPriceDO.setPurchaseServiceFee(airOrderPriceDO.getPurchaseServiceFee().negate());
        airOrderPriceDO.setPurchaseUpgradeFee(airOrderPriceDO.getPurchaseUpgradeFee().negate());
        airOrderPriceDO.setPurchaseChangeFee(airOrderPriceDO.getPurchaseChangeFee().negate());
//        airOrderPriceDO.setPurchaseReturnFee(airOrderPriceDO.getPurchaseReturnFee().negate());
        airOrderPriceDO.setPurchaseTicketPrice(airOrderPriceDO.getPurchaseTicketPrice().negate());
        airOrderPriceDO.setPurchasePrice(airOrderPriceDO.getPurchasePrice().negate());
        airOrderPriceDO.setPurchaseUsedPrice(airOrderPriceDO.getPurchaseUsedPrice().negate());
        airOrderPriceDO.setPurchaseAirportTax(airOrderPriceDO.getPurchaseAirportTax().negate());
        airOrderPriceDO.setPurchaseOilTax(airOrderPriceDO.getPurchaseOilTax().negate());
        airOrderPriceDO.setPurchaseTax(airOrderPriceDO.getPurchaseTax().negate());
//        airOrderPriceDO.setPurchaseAgencyFeeRate(airOrderPriceDO.getPurchaseAgencyFeeRate().negate());
//        airOrderPriceDO.setPurchaseAgencyFee(airOrderPriceDO.getPurchaseAgencyFee().negate());
//        airOrderPriceDO.setPurchaseBackRebateFeeRate(airOrderPriceDO.getPurchaseBackRebateFeeRate().negate());
//        airOrderPriceDO.setPurchaseBackRebateFee(airOrderPriceDO.getPurchaseBackRebateFee().negate());
        airOrderPriceDO.setPurchasePrizePrice(airOrderPriceDO.getPurchasePrizePrice().negate());
        airOrderPriceDO.setPurchasePrizeTax(airOrderPriceDO.getPurchasePrizeTax().negate());
    }
}
